package org.apache.jsp.page;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public final class main_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.List _jspx_dependants;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=GBK");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write(' ');
      out.write('\r');
      out.write('\n');
request.setCharacterEncoding("GBK");
      out.write(" \r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<title>数码产品搜索引擎</title>\r\n");
      out.write("<meta http-equiv=Content-Type content=\"text/html; charset=GBK\">\r\n");
      out.write("\r\n");
      out.write("<script type='text/javascript' src=\"");
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
      out.write("/dwr/engine.js\"></script>\r\n");
      out.write("<script type='text/javascript' src=\"");
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
      out.write("/dwr/util.js\"></script>\r\n");
      out.write("<script type='text/javascript' src=\"");
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
      out.write("/dwr/interface/searchService.js\"></script>\r\n");
      out.write("<script language=\"javascript\">\r\n");
      out.write("\r\n");
      out.write("var request;\r\n");
      out.write("var minpage;\r\n");
      out.write("var maxpage;\r\n");
      out.write("var startindex;\r\n");
      out.write("var hasnext;\r\n");
      out.write("\r\n");
      out.write("function doSearch(type){\r\n");
      out.write("\t\r\n");
      out.write("\tvar result = document.getElementById(\"result\");\r\n");
      out.write("\tvar pagingdiv = document.getElementById('paging');\r\n");
      out.write("\tresult.innerHTML=\"\";\r\n");
      out.write("\tpagingdiv.innerHTML = \"\";\r\n");
      out.write("\r\n");
      out.write("\tif (type != 'paging') {\r\n");
      out.write("\t\tvar startindexinput = document.getElementById('startindex');\r\n");
      out.write("\t\tstartindexinput.value = \"1\";\r\n");
      out.write("\t}\t\r\n");
      out.write("\t\r\n");
      out.write("\trequest = {startindex:1, query:\"\"};\r\n");
      out.write("\r\n");
      out.write("\tDWRUtil.getValues(request);\r\n");
      out.write("\r\n");
      out.write("\tsearchService.getSearchResults(request, fillPage);\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("function fillPage(data){\r\n");
      out.write("\r\n");
      out.write("\tvar list = data.results;\r\n");
      out.write("\tvar resultdiv = document.getElementById('result');\r\n");
      out.write("\tvar pagingdiv = document.getElementById('paging');\r\n");
      out.write("\r\n");
      out.write("\tresultdiv.innerHTML = \"\";\r\n");
      out.write("\tpagingdiv.innerHTML = \"\";\r\n");
      out.write("\r\n");
      out.write("\tif (list.length == 0) {\r\n");
      out.write("\t\tresultdiv.innerHTML = \"<span>Sorry, we can't find what you want...</span>\";\r\n");
      out.write("\t\treturn;\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("\tfor(var i=0; i<list.length; i++) {\r\n");
      out.write("\t\tvar ele = document.createElement('div');\r\n");
      out.write("\t\tele.setAttribute('id','info' + list[i]);\r\n");
      out.write("\t\tele.innerHTML = \"<span>loading..</span>\";\r\n");
      out.write("\t\tresultdiv.appendChild(ele);\r\n");
      out.write("\t\tsearchService.getSearchResultById(list[i], fillDetailResult);\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("\tminpage = data.minpage;\r\n");
      out.write("\tmaxpage = data.maxpage;\r\n");
      out.write("\tstartindex = data.startindex;\r\n");
      out.write("\thasnext = data.hasnext;\r\n");
      out.write("\t\r\n");
      out.write("\tif (minpage != 1) {\r\n");
      out.write("\t\tvar link = document.createElement('a');\r\n");
      out.write("\t\tlink.setAttribute(\"href\",\"javascript:paging('\" + ((minpage-11)*10+1) + \"')\");\r\n");
      out.write("\t\tlink.innerHTML = \"前10页<<\";\r\n");
      out.write("\t\tpagingdiv.appendChild(link);\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("\tfor (var j=minpage; j <=maxpage; j++)\r\n");
      out.write("\t{\r\n");
      out.write("\t\tif ((j-1)*10+1 != startindex)\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\tvar link = document.createElement('a');\r\n");
      out.write("\t\t\tlink.setAttribute(\"href\",\"javascript:paging('\" + ((j-1)*10+1) + \"')\");\r\n");
      out.write("\t\t\tlink.innerHTML = \"第\" + j + \"页\";\r\n");
      out.write("\t\t\tpagingdiv.appendChild(link);\r\n");
      out.write("\t\t}\r\n");
      out.write("\t\telse {\r\n");
      out.write("\t\t\tpagingdiv.innerHTML += (\"第\" + j + \"页\");\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("\tif (hasnext == 1) {\r\n");
      out.write("\t\tvar link = document.createElement('a');\r\n");
      out.write("\t\tlink.setAttribute(\"href\",\"javascript:paging('\" + (maxpage*10+1) + \"')\");\r\n");
      out.write("\t\tlink.innerHTML = \">>后10页\";\r\n");
      out.write("\t\tpagingdiv.appendChild(link);\r\n");
      out.write("\t}\r\n");
      out.write("\t\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("function fillDetailResult(record) {\r\n");
      out.write("\tvar result = document.getElementById('info' + record.id);\r\n");
      out.write("\tresult.innerHTML=\"<table border='0' cellpadding='0' cellspacing='0' width=500><tr><td width='120'><img src='../showpic?id=\" \r\n");
      out.write("\t                  + record.imageUrl + \"' /></td><td><a href='detail.jsp?id=\"\r\n");
      out.write("\t                  + record.id + \r\n");
      out.write("\t                  \"' target='_blank'><font color=#C60A00 size='2'>\"\r\n");
      out.write("\t                  + \"<font size='2'>名称：</font>\" + record.name + \r\n");
      out.write("\t                  \"</font><br>\" + \"<font size='2'>型号：\" + record.type + \"</font><br><font color=#C60A00 size='2'>\"\r\n");
      out.write("\t                  + record.abstractContent + \"......\" + \"</font><br><a href='\" + record.url + \"'>\"\r\n");
      out.write("\t                  + \"<font size=2>\" + record.url + \"</font>\" + \"</a><br><font size='2' color=green>索引时间:</font>\"\r\n");
      out.write("\t                  + \"<font size=2 color=green>\" + record.indexCreateTime + \"</font>\"\r\n");
      out.write("\t                  + \"</td></tr></table>\";\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("function paging(newindex) {\r\n");
      out.write("\tdocument.getElementById('startindex').value = newindex;\r\n");
      out.write("\tdoSearch('paging');\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("function handlekey(){\r\n");
      out.write("\tif (document.getElementById('query').value == '')\r\n");
      out.write("\t\treturn;\r\n");
      out.write("\tvar intkey = -1;\r\n");
      out.write("\tif(window.event) {\r\n");
      out.write("\t\tintKey = event.keyCode;\r\n");
      out.write("\t\tif(intKey == 13){\r\n");
      out.write("\t\t\tdoSearch('');\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write("<input type=\"hidden\" name=\"startindex\" id=\"startindex\" value=\"1\">\r\n");
      out.write("<!-- 这是搜索栏 -->\r\n");
      out.write("<div id=\"searchbar\">\r\n");
      out.write("\t<table align=\"center\">\r\n");
      out.write("\t\t<tr align=\"center\">\r\n");
      out.write("\t\t\t<td>\r\n");
      out.write("\t\t\t\t<img src=\"../image/logo.jpg\" />\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t<tr align=\"center\">\r\n");
      out.write("\t\t\t<td><input size=\"50\" type=\"text\" name=\"query\" id=\"query\" value=\"诺基亚\"  onkeyup=\"handlekey()\">\r\n");
      out.write("\t\t\t<input type=\"button\" value=\"Search\"  id=\"search\" onclick=\"javascript:doSearch('')\"></td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t</table>\r\n");
      out.write("</div>\r\n");
      out.write("\r\n");
      out.write("<hr>\r\n");
      out.write("\r\n");
      out.write("<!-- 这是结果栏 -->\r\n");
      out.write("<div id=\"result\">\r\n");
      out.write("</div>\r\n");
      out.write("\r\n");
      out.write("<hr>\r\n");
      out.write("\r\n");
      out.write("<!-- 这是分页栏 -->\r\n");
      out.write("<div id=\"paging\">\r\n");
      out.write("\r\n");
      out.write("</div>\r\n");
      out.write("\r\n");
      out.write("<!-- 这是Footer -->\r\n");
      out.write("<div id=\"footer\">\r\n");
      out.write("\t<table align=\"center\">\r\n");
      out.write("\t\t<tr align=\"center\">\r\n");
      out.write("\t\t\t<td>\r\n");
      out.write("\t\t\t\t<img src=\"../image/footer.jpg\" />\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t</table>\r\n");
      out.write("</div>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
